


N=$ 

if [ "$N" = "" ];then
	N=$(curl http://behnamghader.net/numofmachines.html)
fi
User=ubuntu
cnt=0
Date=$(date '+%Y-%m-%d-%H-%M-%S')
DestDir=sshOuts/$Date
mkdir $DestDir

for i in $(./getClientsDNSs.sh); do
	
	if [ "$cnt" -ge "$N" ];then
		exit
	fi
	cnt=$((cnt + 1))
	echo $cnt
	DNS=$i
	#./sshChecker.sh $User $DNS	
	echo connecting to client $DNS
	(cat clientCommands | ssh -oStrictHostKeyChecking=no -i key-pair.pem $User@$DNS sh > $DestDir/$DNS.txt) &
done


